package #(package).controller;

import #(package).common.utils.PageUtils;
import #(package).common.utils.R;
import #(package).service.#(className)Service;
import #(package).model.#(className);
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/sys/#(classNameSmall)")
public class Sys#(className)Controller {

	@Autowired
	private #(className)Service #(classNameSmall)Service;

	/**
	 * 列表
	 */
	@ResponseBody
	@GetMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		PageUtils page = #(classNameSmall)Service.queryPage(params);
		return R.ok().put("page", page);
	}

	/**
	 * 详情
	 */
	@ResponseBody
	@GetMapping("/info/{id}")
	public R info(@PathVariable Object id){
        #(className) #(classNameSmall) = #(classNameSmall)Service.findById(id);
		return R.ok().put("#(classNameSmall)", #(classNameSmall));
	}

	/**
	 * 更新
	 */
	@ResponseBody
	@PostMapping("/update")
	public R update(@RequestBody #(className) #(classNameSmall)) {
		#(classNameSmall).update();
		return R.ok();
	}

	/**
	 * 新增
	 */
	@ResponseBody
	@PostMapping("/save")
	public R save(@RequestBody #(className) #(classNameSmall)) {
		#(classNameSmall).save();
		return R.ok();
	}

	/**
	 * 删除
	 */
	@ResponseBody
	@PostMapping("/delete")
    public R delete(@RequestBody Object[] ids) {
        #(classNameSmall)Service.deleteBatch(ids);
        return R.ok();
    }

}
